<?php

namespace app\admin\model;

use think\Model;
use \app\admin\model\Store;

class Manager extends Model
{
    /**
     * 为列表增加商户信息
     * @param $result
     * @return mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function getMananger($result){
        if(!empty($result)){
            foreach ($result as $item){
                $manager = self::find($item['manager_id']);
                $item->manager = $manager['username']?? '';
                if(!empty($item['store_id'])){
                    $store = Store::find($item['store_id']);
                    $item->store_name = $store['name']?? '';
                }
            }
        }
        return $result;
    }
}
